package com.kotlin.android.jetpack.module

import android.content.Context
import com.bumptech.glide.GlideBuilder
import com.bumptech.glide.annotation.GlideModule
import com.bumptech.glide.load.engine.cache.DiskCache
import com.bumptech.glide.load.engine.cache.ExternalPreferredCacheDiskCacheFactory
import com.bumptech.glide.module.AppGlideModule

/**
 * 创建者: zl
 * 创建时间: 2020/6/9 5:28 PM
 * 描述:Glide V4
 */
@GlideModule
class ImageAppGlideModule : AppGlideModule() {
    /**
     * 禁止解析Manifest文件
     */
    override fun isManifestParsingEnabled(): Boolean {
        return false
    }

    override fun applyOptions(context: Context, builder: GlideBuilder) {
        super.applyOptions(context, builder)
        builder.setDiskCache(
            ExternalPreferredCacheDiskCacheFactory(
                context,
                DiskCache.Factory.DEFAULT_DISK_CACHE_SIZE.toLong()
            )
        )
    }
}